package com.epsoft.odin7cj.flow.example;

import java.io.Serializable;
import java.util.List;
import org.activiti.engine.ProcessEngine;
import org.activiti.engine.ProcessEngineConfiguration;
import org.activiti.engine.ProcessEngines;
import org.activiti.engine.RepositoryService;
import org.activiti.engine.RuntimeService;
import org.activiti.engine.TaskService;
import org.activiti.engine.repository.Deployment;
import org.activiti.engine.repository.DeploymentBuilder;
import org.activiti.engine.repository.ProcessDefinition;
import org.activiti.engine.runtime.Execution;
import org.activiti.engine.runtime.ProcessInstance;
import org.activiti.engine.task.Task;

/**
 * 消息开始时间
 * @author Administrator
 *
 */
public class C09MessageStartEvent {

	public static void main1(String[] args) throws Exception {
		
		// 流程引擎
		ProcessEngine engine = ProcessEngines.getDefaultProcessEngine();
		
		// 获取存储服务
		RepositoryService repService = engine.getRepositoryService();
		// 获取运行服务
		RuntimeService runService = engine.getRuntimeService();
		// 获取任务服务
		TaskService taskService = engine.getTaskService();
		
		DeploymentBuilder builder = repService.createDeployment();
		builder = builder.addClasspathResource("bpmn/c09-message-start-event.bpmn");
		// 发布流程
		Deployment deployment = builder.deploy();
		// 获取流程定义
		ProcessDefinition pd = repService.createProcessDefinitionQuery().deploymentId(deployment.getId()).singleResult();

		// 通过消息启动流程实例
		ProcessInstance pi = runService.startProcessInstanceByMessage("bruceTestMessageName");	
		
		System.out.println("\n 实例ID："+pi.getId()); 
		


	}
	
}

	
